﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.WarehouseInsp.Buz.Models;
using FluentValidation;
using FluentValidation.Results;
using Microhard.WarehouseInsp.Buz.Msg;

namespace Microhard.WarehouseInsp.Buz.Validator
{
    public class PlgChangePriceValidator : AbstractValidator<PledgeChangeRecordModel>
    {
        public PlgChangePriceValidator()
        {
            RuleSet("Update", () =>
            {
                Custom(u =>
                {
                    if (u.CurrentAmount <= 0 && u.CurrentPrice <= 0)
                    {
                        return new ValidationFailure("CurrentPrice", ChangePlgPriceMsg.NeedPrice);
                    }
                    return null;
                });
            });
        }
    }
}
